local hx__guangjuexing = fk.CreateSkill{
    name = "hx__guangjuexing",

    tags = {Skill.Compulsory},
}

hx__guangjuexing:addEffect(fk.DamageInflicted,{
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(hx__guangjuexing.name) and target and target == player and data.damage and data.damageType ~= fk.NormalDamage and player:usedSkillTimes(hx__guangjuexing.name,Player.HistoryGame) <= 2
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local suc,dat = room:askToUseActiveSkill(player,{ skill_name = "#hx__guangjuexing__active", cancelable = false , prompt = "#hx__guangjuexing__evoke" })
        if suc and dat and dat.interaction then
            local card = room:getCardsFromPileByRule(dat.interaction,1,"allPiles")
            if card then
                room:moveCardTo(card,Player.Hand,player,fk.ReasonPrey,hx__guangjuexing.name,nil,false,player)
            else
                room:doBroadcastNotify("ShowToast", "牌堆里已经没有你选择的牌了！")  
            end
        end
        data:preventDamage()
    end,
})

hx__guangjuexing:addEffect(fk.PreHpLost,{
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(hx__guangjuexing.name) and target and target == player and player:usedSkillTimes(hx__guangjuexing.name,Player.HistoryGame) <= 2
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local suc,dat = room:askToUseActiveSkill(player,{ skill_name = "#hx__guangjuexing__active", cancelable = false , prompt = "#hx__guangjuexing__evoke" })
        if suc and dat and dat.interaction then
            local card = room:getCardsFromPileByRule(dat.interaction,1,"allPiles")
            if card then
                room:moveCardTo(card,Player.Hand,player,fk.ReasonPrey,hx__guangjuexing.name,nil,false,player)
            else
                room:doBroadcastNotify("ShowToast", "牌堆里已经没有你选择的牌了！")  
            end
        end
        data.prevented = true
    end,
})

return hx__guangjuexing